package com.taikang.hmp.hbusiness.diabetes.measure.sport.action.intface;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.taikang.hmp.frame.common.TKException;
import com.taikang.hmp.frame.common.datastructre.Dto;
import com.taikang.hmp.frame.common.datastructre.support.BaseDto;
import com.taikang.hmp.frame.common.datastructre.support.ResponseDto;
import com.taikang.hmp.frame.common.web.action.BaseAction;
import com.taikang.hmp.hbusiness.diabetes.measure.sport.service.ISportService;

/** 
 * 运动
 * author:qrp
 * time:2015年8月5日 上午11:08:43
 */
public class SportAction extends BaseAction{
	private static Logger logger = LoggerFactory.getLogger(SportAction.class);
	
	
	private ISportService sportService;

	public ISportService getSportService() {
		return sportService;
	}

	public void setSportService(ISportService sportService) {
		this.sportService = sportService;
	}

	public String executeAction(){
		if ("saveSport".equals(requestDto.getMethod())) {
			return saveSport();
		}else{
			throw new TKException("no support method:"+requestDto.getMethod());
		}
	}
	
	/**
	 * 保存运动记录
	 */
	public String saveSport(){
		logger.info("进入saveSport方法体内:"+requestDto.toString());
		ResponseDto responseDto = new ResponseDto();
		//
		Dto paramDto = new BaseDto();
		paramDto = requestDto.getRequestlist().get(0);
		paramDto = super.appendRequestBase(paramDto, requestDto);
		//paramDto.put("requestlist",requestDto.getRequestlist());
		
		//
		String result = sportService.saveSport(paramDto);
		if (result != null) {
			responseDto.addError(result);
		} else {
			Dto resultDto = new BaseDto();
			resultDto.put("result", Boolean.TRUE);
			responseDto.pushResultDto(resultDto);
			//
		}
		super.setDataMap(responseDto);
		logger.info("saveSport已成功返回结果:" + responseDto.toString());
		return SUCCESS;
	}
	
}
